package com.eairlv.route.demo.client;

import com.eairlv.route.client.annotation.RouteKey;
import com.eairlv.route.client.annotation.RouteParameter;
import com.eairlv.route.client.configuration.RouteConfiguration;
import com.eairlv.route.demo.client.entity.form.RouteForm;
import com.eairlv.route.demo.entity.Result;
import com.eairlv.route.demo.client.entity.vo.RouteVO;
import com.eairlv.route.demo.config.route.CustomRoute;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.List;

/**
 * @author eairlv
 * @description
 * @date 17:28 2019/10/15
 */
@FeignClient(name = "", configuration = RouteConfiguration.class)
public interface FeignRouteClient {

    /**
     * 基础方式
     * @param locationForm
     * @return
     */
    @GetMapping("/route")
    @RouteKey("#locationForm")
    Result<RouteVO> getRoute(RouteForm locationForm);

    /**
     * 额外参数方式
     * @param id
     * @return
     */
    @GetMapping("/route/{id}")
    @RouteKey("#customRoute")
    Result<RouteVO> getRoute(@PathVariable("id") Integer id, CustomRoute customRoute);

    /**
     * list参数
     * @param routeForms
     * @return
     */
    @PostMapping("/route")
    @RouteKey("#routeForms.get(0)")
    Result<RouteVO> getRoute(@RouteParameter("routeForms") @RequestBody List<RouteForm> routeForms);
}
